package com.lc.YYGH.cmn.listener;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.lc.YYGH.cmn.mapper.DictMapper;
import com.lc.YYGH.model.cmn.Dict;
import com.lc.YYGH.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper)
    {
        this.dictMapper=dictMapper;
    }
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext context) {
        Dict dict=new Dict();
        BeanUtils.copyProperties(dictEeVo,dict);
        //插入到数据库中
        dictMapper.insert(dict);

    }
   //所有数据读完以后就自动调用
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {


    }
}
